@echo off
chcp 65001
setlocal enabledelayedexpansion

:: Check dependencies
where docker >nul 2>nul
if %ERRORLEVEL% neq 0 (
    echo Error: Docker not found. Please install Docker first.
    exit /b 1
)

where docker-compose >nul 2>nul
if %ERRORLEVEL% neq 0 (
    echo Error: Docker Compose not found. Please install Docker Compose first.
    exit /b 1
)

:: Create data directory
if not exist "data" (
    echo Creating data directory...
    mkdir data
)

:: Main program
echo Starting installation...

:: Stop existing services
echo Stopping existing services...
docker-compose down --remove-orphans

:: Build and start services
echo Building and starting services...
docker-compose up --build -d

:: Check result
if %ERRORLEVEL% equ 0 (
    echo Installation successful!
    echo Access URL: http://localhost:5000
) else (
    echo Installation failed. Please check logs.
    docker-compose logs
    exit /b 1
)

endlocal 